#!/usr/bin/env ruby

class Svn_batch < Svn
  
#   https://svn.dtvops.net/dev/projects/contentManagement/contentServices/CS/CSControlAssetFlow/branches/dev_3.0
  SVN_HOST = "https://svn.dtvops.net/dev"
  SVN_HOST_CS = "/projects/contentManagement/contentServices/CS"
  SVN_BRANCHES_NAME = "branches"
  
  def hash_CS_BS
    {
"CSCalculateCSSID" => {"source"=>"trunk"},
"CSControlAssetFlow" => {"source"=>"branches/dev_1.1"},
"CSIngestContent" => {"source"=>"branches/dev_1.1"},
"CSNotificationService" => {"source"=>"branches/dev_1.1"},
"CSProcessBroadbandHome" => {"source"=>"tags/1.1.1"},
"CSProcessContentMedia" => {"source"=>"tags/1.1.0"},
"CSProcessDLSNotifications" => {"source"=>"trunk"},
"CSProcessExtendHPEvent" => {"source"=>"tags/1.1.1"},
"CSProcessFile" => {"source"=>"branches/dev_1.1"},
"CSProcessHomepagePackage" => {"source"=>"branches/dev_1.1"},
"CSProcessProvider" => {"source"=>"tags/1.1.2"},
"CSProcessRowAd" => {"source"=>"branches/dev_1.1"},
"CSProcessRowAdEvent" => {"source"=>"tags/1.1.1"},
"CSProcessServiceCategory" => {"source"=>"tags/1.1.0"},
"CSProcessTitlePackage" => {"source"=>"branches/dev_1.1"},
"CSProcessWatchFolder" => {"source"=>"branches/dev_1.1"},
"CSPurgeContent" => {"source"=>"branches/dev_1.1"},
"CSSharedBR" => {"source"=>"branches/dev_1.1"},
"CSSharedResources" => {"source"=>"branches/dev_1.1"},
"CSValidateContentMetadata" => {"source"=>"branches/dev_1.1"}
    }
  end
  
  def svn_new_brach(branch_name = "dev_3.0")
    message = "'New branch " + branch_name + " created.'"
    hash_CS_BS.each_pair do |k, e|
      src = SVN_HOST + SVN_HOST_CS  + "/" + k + "/" + e["source"]
      dist = SVN_HOST + SVN_HOST_CS  + "/" + k + "/" + SVN_BRANCHES_NAME + "/" + branch_name
      
      begin
#        svn_cmd "rm", dist, ["-m", message]
      rescue
      end
      begin
       svn_cmd "cp", [src, dist], ["-m", message]
      rescue
      end
    end
  end
  
end
